package com.lxb;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

/**
 * 中序遍历  递归
 */
public class InorderTraversal {
    public static void main(String[] args) {
        TreeNode root = new TreeNode(5);
        TreeNode l_num1 = new TreeNode(3);
        TreeNode l_num2 = new TreeNode(1);
        TreeNode r_num1 = new TreeNode(8);
        TreeNode r_num2 = new TreeNode(4);
        List<Integer> list = new ArrayList<Integer>();
        root.left = l_num1;
        root.right = r_num1;
        root.left.left = l_num2;
        root.left.right = r_num2;

        dfs(list,root);


        System.out.println(list.toString());
    }


    public static void dfs(List<Integer> list,TreeNode root){
        if(root == null){
            return;
        }
        dfs(list,root.left);
        list.add(root.val);
        dfs(list,root.right);
    }

}
